package com.tbs.parkingsaleapp.Http.Listenner;

import android.view.View;
import android.widget.Toast;
import com.tbs.parkingsaleapp.Http.HttpHelper;
import com.tbs.parkingsaleapp.SystemManager.NetWorkSetting;
import abstergo.tbs.betterasyc.AsycBase.IAsycBackgroundAction;
import abstergo.tbs.betterasyc.AsycBase.IAsycResultAction;

public class PutOrderHttper implements IAsycBackgroundAction<Object, Integer>, IAsycResultAction<Integer> {
    View context;
    public PutOrderHttper(View context)
    {
        this.context=context;
    }
    @Override
    public Integer BackGroundAction(Object... params) throws Exception{
        String r= HttpHelper.Get(NetWorkSetting.PutOrderUrl(params[0].toString(), (Integer) params[1], (Integer)params[2])).trim();
        return Integer.valueOf(r);
    }

    @Override
    public void ResultFunction(Integer result) {
        switch (result)
        {
            case 1:
                Toast.makeText(context.getContext(),"下单成功",Toast.LENGTH_SHORT).show();
                break;
            case -4:
                Toast.makeText(context.getContext(),"已存在订单",Toast.LENGTH_SHORT).show();
                break;
            case -2:
                Toast.makeText(context.getContext(),"小区与车位信息错误",Toast.LENGTH_SHORT).show();
                break;
            case -3:
                Toast.makeText(context.getContext(),"车位状态错误",Toast.LENGTH_SHORT).show();
                break;
            case -5:
                Toast.makeText(context.getContext(),"下单人信息有误",Toast.LENGTH_SHORT).show();
                break;
            case -7:
                Toast.makeText(context.getContext(),"下单人无权购买",Toast.LENGTH_SHORT).show();
                break;
        }
        context.setEnabled(true);
    }
}
